import types from '../types';
// console.log(types);

const state = {
    Numbers: 0,
    catchPages: ["mine", "home"]
}

const getters = {
    Numbers(state) {
        return state.Numbers
    },
    catchPages(context) {
        return context.catchPages;
    }
}

const mutations = {
    [types.INCREMENT](state) {
        return state.Numbers++
    },
    [types.DECREMENT](state) {
        return state.Numbers--
    },
    [types.PAGEINCREMENT](state, item) {
        if (state.catchPages.indexOf(item) === -1) {
            state.catchPages.push(item);
        }
    },
    [types.PAGEDECREMENT](state, item) {
        let index = state.catchPages.indexOf(item);
        if (index > 0) {
            state.catchPages.splice(index, 1)
        }
    },
}

const actions = {
    increment({ commit, state }) {
        commit(types.INCREMENT)
    },
    decrement({ commit, state }) {
        commit(types.DECREMENT)
    },
    add({ commit, state }) {
        commit(types.DECREMENT)
    },
    remove({ commit, state }) {
        commit(types.DECREMENT)
    }
}

export default {
    state,
    getters,
    actions,
    mutations
}